﻿using Microsoft.CodeAnalysis.Operations;
using NPOI.Util;
using SmartPlant.Model;
using SmartPlant.Model.Biz;
using SmartPlant.Model.DbContext;
using SmartPlant.Services.Interfaces;
using SmartPlant.WinCore;
using System.Collections.Generic;
using System.Threading.Tasks;
using static System.Formats.Asn1.AsnWriter;

namespace SmartPlant.Services
{
    public class ProjectService : BaseService, IProjectService
    {
        #region Project
        public async Task<bool> DomainConnectAsync(string proLogName, string proLogPass)
        {
            string uri = $"/api/project/domain-conn/{proLogName}/{proLogPass}";
            var res = await GetAsync<string>(uri);
            var data = res.data;


            return data.IsNotEmptyOrNull();
        }

        public async Task<List<Project>> GetDomainsAsync()
        {
            string uri = $"/api/project/domains";
            var res = await GetAsync<List<Project>>(uri);
            return res.data;
        }



        public async Task<List<T>> QueryBySQL1<T>(decimal projId, string SQL, SchemaLevel schemaLevel)
        {
            {
                //https://localhost:44358/api/project/1/sql/select%20%2A%20from%20spec_sheet_data%20where%20cmpnt_id%3D1/domain
                string uri = $"/api/Project/{projId}/sql/{SQL}/{schemaLevel}";
                var res = await GetAsync<List<T>>(uri);
                return res.data;
            }
        }
        #endregion
    }
}